package com.umakr.ax.app.web;


import com.umakr.ax.app.service.SpreadContentWebService;
import com.umakr.ax.common.service.SpreadContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import io.swagger.annotations.ApiOperation;

import com.umakr.ax.core.base.AbstractController;

/**
 * <p>
 * 推广内容  前端控制器
 * </p>
 *
 * @author Umakr-Code-Generator
 * @since 2017-12-30
 */
@Controller
@RequestMapping("/api/web/spreadContent")
public class SpreadContentWebController extends AbstractController {
	@Autowired
	SpreadContentWebService spreadContentWebService;

	@ApiOperation(value = "获取结果页面列表")
	@GetMapping("/listSpreadResult")
	@ResponseBody
	public Object listSpreadResult(ModelMap modelMap,@RequestParam(name = "rsId") Long rsId,Long spreadId,String searchText) {
		return setSuccessModelMap(modelMap,spreadContentWebService.listSpreadResult(rsId,spreadId,searchText));
	}

	@ApiOperation(value = "根据ID获取详情页面")
	@GetMapping("/getSpreadContentById")
	@ResponseBody
	public Object getSpreadContentById(ModelMap modelMap,@RequestParam(name = "id") Long id) {
		return setSuccessModelMap(modelMap,spreadContentWebService.getSpreadContentById(id));
	}

	@ApiOperation(value = "生成推广内容页面")
	@PostMapping("/createSpreadContent")
	@ResponseBody
	public Object createSpreadContent(ModelMap modelMap,Long id,@RequestParam(name = "rsId") Long rsId,@RequestParam(name = "title") String title,String content) {
		return setSuccessModelMap(modelMap,spreadContentWebService.createSpreadContent(id,rsId,title,content));
	}

	@ApiOperation(value = "删除推广内容页面")
	@GetMapping("/delSpreadContent")
	@ResponseBody
	public Object delSpreadContent(ModelMap modelMap,@RequestParam(name = "id") Long id) {
		return setSuccessModelMap(modelMap,spreadContentWebService.delSpreadContent(id));
	}

}